/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
/* Copyright (C) 2012 Zongyou Yao. All rights reserved.     */

#include "stack.h"
#include "unittest.h"

int main(int argc, char **argv)
{
    long a[] = {0, 1, 2, 3, 4, 5};

    stack_t stack = stack_new();

    ASSERT_EQ(stack_empty(stack), 1);

    int i;
    for (i = 0; i != sizeof(a) / sizeof(*a); ++i) {
        stack_push(stack, &a[i]);
    }

    ASSERT_EQ(stack_empty(stack), 0);

    for (i = 0; i != sizeof(a) / sizeof(*a); ++i) {
        long *j = stack_pop(stack);
        ASSERT_EQ(*j, a[sizeof(a) / sizeof(*a) - i - 1]);
    }

    ASSERT_EQ(stack_empty(stack), 1);

    stack_free(&stack);
    return 0;
}
